package cn.bob.basic.controller;

import cn.bob.basic.dto.PhoneEmailDto;
import cn.bob.basic.service.IRegisterServer;
import cn.bob.basic.utils.AjaxResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author bob
 * @data 2022/10/19-15:45
 */
@Slf4j
@RestController
@RequestMapping("/register")
public class RegisterController {

    @Autowired
    private IRegisterServer server;



    @PostMapping("/phone")
    public AjaxResult phoneCreate(@RequestBody @Valid PhoneEmailDto phoneDto){
        server.phoneCreate(phoneDto);
        return AjaxResult.me().success(phoneDto);
    }
    @PostMapping("/email")
    public AjaxResult emailCreate(@RequestBody @Valid PhoneEmailDto emailDto){
        server.emailCreate(emailDto);
        return AjaxResult.me().success(emailDto);
    }
}
